﻿namespace Confluxx.Common.Logging.Core
{
	public static class LogExtensions
	{
		/// <summary>
		/// Writes a message to the calling object's logger that the execution of a method has started.
		/// </summary>
		/// <param name="loggingObject">Object that implements the ILog interface</param>
		/// <param name="methodName">The method name to include in the message.</param>
		public static void EnterMethod(this ILog loggingObject, string methodName)
		{
			if (loggingObject != null)
			{
				loggingObject.Logger.EnterMethod(methodName);
			}
		}

		/// <summary>
		/// Writes a message to the calling object's logger that the execution of a method has ended.
		/// </summary>
		/// <param name="loggingObject">Object that implements the ILog interface</param>
		/// <param name="methodName">The method name to include in the message.</param>
		public static void LeaveMethod(this ILog loggingObject, string methodName)
		{
			if (loggingObject != null)
			{
				loggingObject.Logger.LeaveMethod(methodName);
			}
		}

		/// <summary>
		/// Writes a message to the calling object's logger.
		/// </summary>
		/// <param name="loggingObject">Object that implements the ILog interface</param>
		/// <param name="message">The message that should be logged.</param>
		public static void LogMessage(this ILog loggingObject, string message)
		{
			if (loggingObject != null)
			{
				loggingObject.Logger.LogMessage(message);
			}
		}
	}
}